using System.ComponentModel.DataAnnotations;

namespace Crux.Core.Validations;
/// <summary>
/// ValidateExtensions
/// </summary>
public static class ValidateExtensions
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="object"></param>
    /// <param name="results"></param>
    /// <param name="validateAllProperties"></param>
    /// <returns></returns>
    [DebuggerStepThrough]
    public static bool Proof(
        this object @object,
        out ICollection<ValidationResult> results,
        bool validateAllProperties = true)
    {
        var context = new ValidationContext(@object);
        results = new List<ValidationResult>();

        return Validator.TryValidateObject(@object, context, results, validateAllProperties);
    }
}